<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>
    <style>
      #header {
        height: 100px;
        background: #aef;
      }

      #main {
        height: 400px;
        background: rgb(61, 133, 151);
      }

      #footer {
        height: 100px;
        background: rgb(29, 83, 138);
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      //声明一个类 『类名首字母一定要大写』
      class Top extends React.Component{
        //必须要声明 render 方法, 且 render 要返回值, 一般返回『虚拟 DOM 对象』
        render(){
          return <div id="header"></div>;
        }
      }

      class Main extends React.Component{
        render(){
          return <div id="main"></div>;
        }
      }

      class Footer extends React.Component{
        render(){
          return <div id="footer"></div>;
        }
      }

      //声明虚拟DOM对象
      // <Top></Top>  在渲染的时候, 将自动寻找同名的『类』, 
      //              然后实例化对象, 然后实例化对象调用 render 方法, 得到虚拟 DOM 对象
      class App extends React.Component{
        render(){
          //返回虚拟DOM对象
          return <div>
                <Top></Top>
                <Main />
                <Footer />
                </div>
        }
      }

      ReactDOM.render(<App />, document.querySelector('#root'));
    </script>
  </body>
</html>
